﻿using SYSoft.Model.Models.DeviceManage.Maintain;
using SYSoft.Repository;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace SYSoft.Services.MaintainManage
{


    public interface IWH_knowledgeServices : IBaseServices<WH_knowledge>
    {
      

        /// <summary>
        /// 模糊查询条件
        /// </summary>
        /// <returns></returns>
        Task<List<WH_knowledge>> listSelect(string devicename, string str);
    }



    public class WH_knowledgeServices : BaseServices<WH_knowledge>, IWH_knowledgeServices
    {
        public WH_knowledgeServices(IBaseRepository<WH_knowledge> BaseDal) : base(BaseDal)
        {

        }
        

        public async Task<List<WH_knowledge>> listSelect(string devicename, string str)
        {
            if (string.IsNullOrEmpty( devicename ))
            {
                return await Query(d => d.ProblemDes.Contains(str));
            }
            if(string.IsNullOrEmpty(str))
            {
                return await Query(d => d.DeviceName==devicename);
            }

            return await Query(d => d.DeviceName == devicename && d.ProblemDes.Contains(str));

        }

    }
}
